var dialogA = (function(window) {
  var selectBox = function selectBox(option){
    this.version = '1.0.0';
    this.inHtml=""
    var self = this;
    defaultOpt = {
        callbackYes:null,
        callbackCancel:null,
        title:null,
        content:[]
    };
    for (var item in defaultOpt) {
      console.log(option)
      if (option[item]) {
          defaultOpt[item] = option[item];
      }
    }
    this.option = defaultOpt;
    var style = ".dialog_show{-webkit-transform:translateY(0)!important;-moz-transform:translateY(0)!important;-ms-transform:translateY(0)!important;-o-transform:translateY(0)!important;transform:translateY(0)!important}.dialog_layout{height:100%;width:100%;position:fixed;left:0;top:0;z-index:99999999;-webkit-transform:translateY(100%);-moz-transform:translateY(100%);-ms-transform:translateY(100%);-o-transform:translateY(100%);transform:translateY(100%);-webkit-transition:all linear .2s;-moz-transition:all linear .2s;-ms-transition:all linear .2s;-o-transition:all linear .2s;transition:all linear .2s}.dialog_mark{background:rgba(0,0,0,.6);height:100%;width:100%;position:absolute;left:0;top:0}.cashier_dialog{background:#fff;position:fixed;right:0;bottom:0;top:0;left:0;margin:auto;width:300px;height:250px}.displayNone{display:none!important}.displayBlock{display:block!important}.cashier_dialog_tit{text-align:center;font-size:18px;padding:20px}.cashier_dialog_content{font-size:14px;padding-left:10px;margin-bottom:5px}.cashier_dialog_btn{height:40px;width:90%;margin:10px auto 0;border-radius:5px;background:#3fc26e;text-align:center;line-height:40px}.cashier_dialog_btn_yes{background:#3fc26e;color:white}.cashier_dialog_btn_cancel{background:#f2f2f2}"
    $('head').append('<style type="text/css" class="dialog_style">'+style+'</style>');
    for(var i=0;i<defaultOpt.content.length;i++){
         this.inHtml+='<p class="cashier_Tips_content">'+defaultOpt.content[i]+'</p>'
    }
    console.log(this.inHtml)
    var html= '<div class="dialog_layout">'+
               '<div class="dialog_mark"></div>  '+
               '<div id="cashier_dialog" class="cashier_dialog">'+
                '<p class="cashier_dialog_tit">'+defaultOpt.title+'</p>'+
                this.inHtml;
    if(this.option.callbackYes != null){
        html = html + '<div class="cashier_dialog_btn cashier_dialog_btn_yes">确认</div>';
    }
    html = html + '<div class="cashier_dialog_btn cashier_dialog_btn_cancel">取消</div>'+
               '</div>'+
              ' </div>';
    $('body').append(html);
     this.dom = $('.' +"dialog_layout");
        this.domStyle=$("."+"dialog_style");
        this.init = function() {
            $(".dialog_mark").click(function(evt){
               self.hide(self.dom);
            })
             $(".cashier_dialog_btn_yes").click(function(evt){
                 self.hide(self.dom);
                 self.callbackYes();
            })
              $(".cashier_dialog_btn_cancel").click(function(evt){
                 self.hide(self.dom);
                 self.callbackCancel();
            })
        }
    this.init();
    return this;
  }
  //显示
  selectBox.prototype.show = function() {
      var self = this;
      setTimeout(function() {
          self.dom.addClass('dialog_show');
      }, 200);
      return this;
  }
  // 点击确定的回调函数
  selectBox.prototype.callbackYes= function() {
    this.option.callbackYes() 
  }
  selectBox.prototype.callbackCancel = function() {
    this.option.callbackCancel() 
  }
  //关闭页面
  selectBox.prototype.hide = function() {
    var self=this
    this.dom.removeClass('dialog_show');
    return this;
  }
  return selectBox;
})();
